@import '../../style/themes/default';
@import '../../style/mixins/index';

@avatar-prefix-cls: ~'@{c7n-prefix}-avatar';

.@{avatar-prefix-cls} {
  .reset-component;
  position: relative;
  display: inline-block;
  overflow: hidden;
  color: @avatar-color;
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
  background: @avatar-bg;

  &-image {
    background: transparent;
  }

  .avatar-size(@avatar-size-base, @avatar-font-size-base);

  &-lg {
    .avatar-size(@avatar-size-lg, @avatar-font-size-lg);
  }

  &-sm {
    .avatar-size(@avatar-size-sm, @avatar-font-size-sm);
  }

  &-square {
    border-radius: @avatar-border-radius;
  }

  & > img {
    display: block;
    width: 100%;
    height: 100%;
  }

  &-group {
    display: inline-flex;
  
    .@{avatar-prefix-cls} {
      border: 0.01rem solid @avatar-color;
  
      &:not(:first-child) {
        margin-left: @avatar-group-overlapping;
      }
    }
  
    &-popover {
      .@{c7n-prefix}-avatar + .@{c7n-prefix}-avatar {
        margin-left: @avatar-group-space;
      }
    }

    &-lg {
      .avatar-size(@avatar-size-lg, @avatar-font-size-lg);
    }
  
    &-sm {
      .avatar-size(@avatar-size-sm, @avatar-font-size-sm);
    }
  }
  
}

.avatar-size(@size, @font-size) {
  width: @size;
  height: @size;
  line-height: @size;
  border-radius: 50%;

  & > * {
    line-height: @size;
  }

  &-string {
    position: absolute;
    left: 50%;
    transform-origin: 0 center;
  }

  &.@{avatar-prefix-cls}-icon {
    font-size: @font-size;
  }
}
